from selenium import webdriver
import time

# 初始化浏览器驱动
driver = webdriver.Chrome()
# 先访问淘宝首页（必须先访问，否则添加Cookie会报域名错误）
driver.get("https://www.taobao.com")

# 添加手动获取的Cookie（需替换为实际的name和value）
cookies = [
    {"name": "_m_h5_tk", "value": "30f221700d467112dc71368f29344710_1762075565820"},
    {"name": "_m_h5_tk_enc", "value": "2116b956ce3dafddcda3d25dd4236d52"},
    {"name": "cookie2", "value": "17e2fca7a0badef1a9bfa4fbdabcd6c5"},
    {"name": "cna", "value": "8m2LIZG55V0CAXQEYMuLwi08"},
    {"name": "uc1", "value": "cookie14=UoYY4vIPy1yuhQ%3D%3D&pas=0&cookie15=Vq8l%2BKCLz3%2F65A%3D%3D&existShop=false&cookie16=WqG3DMC9UpAPBHGz5QBErFxlCA%3D%3D&cookie21=UIHiLt3xTIkz"},
    {"name": "lgc", "value": "tb262386910"},
    {"name": "tracknick", "value": "tb262386910"},
    {"name": "isg", "value": "BCIin-15v3oZuqOl49gYUYCDc6iEcyaNIwlBIWy7BxVAP8K5VANPnaitbXvDL54l"},
]

for cookie in cookies:
    driver.add_cookie(cookie)

# 刷新页面，使Cookie生效
driver.refresh()
time.sleep(5)  # 等待页面加载


# 关闭浏览器
driver.quit()